<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background-color: pink;
            padding: 10px;
        }
    </style>
</head>

<body>
    <div class="box" style="width:200px"></div>
    <script>
        //offset系列与style的区别
        var box = document.querySelector('.box');
        console.log(box.offsetWidth); //220
        console.log(box.style.width); //200
        //box.offsetWidth = '330px'; // offsetWidth等属性是只读属性,只能获取不能赋值(这时候只能通过style去改width)
        box.style.width = '330px'; //style.width是可读写属性,既可以获取也可以赋值
        console.log(box.offsetWidth); //350
    </script>
</body>

</html>